local OVALE, Ovale = ...
local OvaleScripts = Ovale.OvaleScripts

do
	local name = "simulationcraft_paladin_Holy"
	local desc = "[6.1] AttiMod: Paladin_Holy_T17M"
	local code = [[

	
Define(infusion_of_light_buff 54149)
Define(holy_radiance 82327)
Define(ethernal_flame_talent 8)

#LayOnHands
AddListItem(LayOnHands lol0 "LayOnHands  0")
AddListItem(LayOnHands lol1 "LayOnHands  10")
AddListItem(LayOnHands lol2 "LayOnHands  20")
AddListItem(LayOnHands lol3 "LayOnHands  30")
AddListItem(LayOnHands lol4 "LayOnHands  40")
AddListItem(LayOnHands lol5 "LayOnHands  50" default)
AddListItem(LayOnHands lol6 "LayOnHands  60")
AddListItem(LayOnHands lol7 "LayOnHands  70")
AddListItem(LayOnHands lol8 "LayOnHands  80")
AddListItem(LayOnHands lol9 "LayOnHands  90")
AddListItem(LayOnHands lol10 "LayOnHands  100")

AddFunction LayOnHandsValue asValue=1
{
	if List(LayOnHands lol0) 0
	if List(LayOnHands lol1) 10
	if List(LayOnHands lol2) 20
	if List(LayOnHands lol3) 30
	if List(LayOnHands lol4) 40
	if List(LayOnHands lol5) 50
	if List(LayOnHands lol6) 60
	if List(LayOnHands lol7) 70    
	if List(LayOnHands lol8) 80 
	if List(LayOnHands lol9) 90 
	if List(LayOnHands lol10) 101 
}

#WoG
AddListItem(WoG wog0 "WoG_EthernalFlame  0")
AddListItem(WoG wog1 "WoG_EthernalFlame  55")
AddListItem(WoG wog2 "WoG_EthernalFlame  60")
AddListItem(WoG wog3 "WoG_EthernalFlame  65")
AddListItem(WoG wog4 "WoG_EthernalFlame  70")
AddListItem(WoG wog5 "WoG_EthernalFlame  75" default)
AddListItem(WoG wog6 "WoG_EthernalFlame  80")
AddListItem(WoG wog7 "WoG_EthernalFlame  85")
AddListItem(WoG wog8 "WoG_EthernalFlame  90")
AddListItem(WoG wog9 "WoG_EthernalFlame  95")
AddListItem(WoG wog10 "WoG_EthernalFlame  100")

AddFunction WoGValue asValue=1
{
	if List(WoG wog0) 0
	if List(WoG wog1) 55
	if List(WoG wog2) 60
	if List(WoG wog3) 65
	if List(WoG wog4) 70
	if List(WoG wog5) 75
	if List(WoG wog6) 80
	if List(WoG wog7) 85    
	if List(WoG wog8) 90 
	if List(WoG wog9) 95 
	if List(WoG wog10) 101 
}

#FlashOfLight
AddListItem(FlashOfLight fol0 "FlashOfLight  0")
AddListItem(FlashOfLight fol1 "FlashOfLight  10")
AddListItem(FlashOfLight fol2 "FlashOfLight  20")
AddListItem(FlashOfLight fol3 "FlashOfLight  30")
AddListItem(FlashOfLight fol4 "FlashOfLight  40")
AddListItem(FlashOfLight fol5 "FlashOfLight  50" default)
AddListItem(FlashOfLight fol6 "FlashOfLight  60")
AddListItem(FlashOfLight fol7 "FlashOfLight  70")
AddListItem(FlashOfLight fol8 "FlashOfLight  80")
AddListItem(FlashOfLight fol9 "FlashOfLight  90")
AddListItem(FlashOfLight fol10 "FlashOfLight  100")

AddFunction FlashOfLightValue asValue=1
{
	if List(FlashOfLight fol0) 0
	if List(FlashOfLight fol1) 10
	if List(FlashOfLight fol2) 20
	if List(FlashOfLight fol3) 30
	if List(FlashOfLight fol4) 40
	if List(FlashOfLight fol5) 50
	if List(FlashOfLight fol6) 60
	if List(FlashOfLight fol7) 70    
	if List(FlashOfLight fol8) 80 
	if List(FlashOfLight fol9) 90 
	if List(FlashOfLight fol10) 101 
}

#HolyLight
AddListItem(HolyLight ol0 "HolyLight  0")
AddListItem(HolyLight ol1 "HolyLight  55")
AddListItem(HolyLight ol2 "HolyLight  60")
AddListItem(HolyLight ol3 "HolyLight  65")
AddListItem(HolyLight ol4 "HolyLight  70")
AddListItem(HolyLight ol5 "HolyLight  75" default)
AddListItem(HolyLight ol6 "HolyLight  80")
AddListItem(HolyLight ol7 "HolyLight  85")
AddListItem(HolyLight ol8 "HolyLight  90")
AddListItem(HolyLight ol9 "HolyLight  95")
AddListItem(HolyLight ol10 "HolyLight  100")

AddFunction HolyLightValue asValue=1
{
	if List(HolyLight ol0) 0
	if List(HolyLight ol1) 55
	if List(HolyLight ol2) 60
	if List(HolyLight ol3) 65
	if List(HolyLight ol4) 70
	if List(HolyLight ol5) 75
	if List(HolyLight ol6) 80
	if List(HolyLight ol7) 85    
	if List(HolyLight ol8) 90 
	if List(HolyLight ol9) 95 
	if List(HolyLight ol10) 101 
}

#HandOfSacrifice
AddListItem(HandOfSacrifice hos0 "HandOfSacrifice  0")
AddListItem(HandOfSacrifice hos1 "HandOfSacrifice  10")
AddListItem(HandOfSacrifice hos2 "HandOfSacrifice  15")
AddListItem(HandOfSacrifice hos3 "HandOfSacrifice  20")
AddListItem(HandOfSacrifice hos4 "HandOfSacrifice  25")
AddListItem(HandOfSacrifice hos5 "HandOfSacrifice  30" default)
AddListItem(HandOfSacrifice hos6 "HandOfSacrifice  35")
AddListItem(HandOfSacrifice hos7 "HandOfSacrifice  40")
AddListItem(HandOfSacrifice hos8 "HandOfSacrifice  45")
AddListItem(HandOfSacrifice hos9 "HandOfSacrifice  50")
AddListItem(HandOfSacrifice hos10 "HandOfSacrifice  100")

AddFunction HandOfSacrificeValue asValue=1
{
	if List(HandOfSacrifice hos0) 0
	if List(HandOfSacrifice hos1) 10
	if List(HandOfSacrifice hos2) 15
	if List(HandOfSacrifice hos3) 20
	if List(HandOfSacrifice hos4) 25
	if List(HandOfSacrifice hos5) 30
	if List(HandOfSacrifice hos6) 35
	if List(HandOfSacrifice hos7) 40    
	if List(HandOfSacrifice hos8) 45 
	if List(HandOfSacrifice hos9) 50 
	if List(HandOfSacrifice hos10) 101 
}







#DivineProtection
AddListItem(DivineProtection dp0 "DivineProtection  0")
AddListItem(DivineProtection dp1 "DivineProtection  10")
AddListItem(DivineProtection dp2 "DivineProtection  20")
AddListItem(DivineProtection dp3 "DivineProtection  30")
AddListItem(DivineProtection dp4 "DivineProtection  40")
AddListItem(DivineProtection dp5 "DivineProtection  50" default)
AddListItem(DivineProtection dp6 "DivineProtection  60")
AddListItem(DivineProtection dp7 "DivineProtection  70")
AddListItem(DivineProtection dp8 "DivineProtection  80")
AddListItem(DivineProtection dp9 "DivineProtection  90")
AddListItem(DivineProtection dp10 "DivineProtection  100")

AddFunction DivineProtectionValue asValue=1
{
	if List(DivineProtection dp0) 0
	if List(DivineProtection dp1) 10
	if List(DivineProtection dp2) 20
	if List(DivineProtection dp3) 30
	if List(DivineProtection dp4) 40
	if List(DivineProtection dp5) 50
	if List(DivineProtection dp6) 60
	if List(DivineProtection dp7) 70    
	if List(DivineProtection dp8) 80 
	if List(DivineProtection dp9) 90 
	if List(DivineProtection dp10) 101 
}

#LightOfDawnNum
AddListItem(LightOfDawnNum lod0 "LightOfDawnNum  0")
AddListItem(LightOfDawnNum lod1 "LightOfDawnNum  1")
AddListItem(LightOfDawnNum lod2 "LightOfDawnNum  2")
AddListItem(LightOfDawnNum lod3 "LightOfDawnNum  3")
AddListItem(LightOfDawnNum lod4 "LightOfDawnNum  4")
AddListItem(LightOfDawnNum lod5 "LightOfDawnNum  5" default)
AddListItem(LightOfDawnNum lod6 "LightOfDawnNum  6")
AddListItem(LightOfDawnNum lod7 "LightOfDawnNum  7")
AddListItem(LightOfDawnNum lod8 "LightOfDawnNum  8")
AddListItem(LightOfDawnNum lod9 "LightOfDawnNum  9")
AddListItem(LightOfDawnNum lod10 "LightOfDawnNum  100")

AddFunction LightOfDawnNumValue asValue=1
{
	if List(LightOfDawnNum lod0) 0
	if List(LightOfDawnNum lod1) 1
	if List(LightOfDawnNum lod2) 2
	if List(LightOfDawnNum lod3) 3
	if List(LightOfDawnNum lod4) 4
	if List(LightOfDawnNum lod5) 5
	if List(LightOfDawnNum lod6) 6
	if List(LightOfDawnNum lod7) 7    
	if List(LightOfDawnNum lod8) 8 
	if List(LightOfDawnNum lod9) 9 
	if List(LightOfDawnNum lod10) 101 
}

#HolyRadianceNum
AddListItem(HolyRadianceNum or0 "HolyRadianceNum  0")
AddListItem(HolyRadianceNum or1 "HolyRadianceNum  1")
AddListItem(HolyRadianceNum or2 "HolyRadianceNum  2")
AddListItem(HolyRadianceNum or3 "HolyRadianceNum  3")
AddListItem(HolyRadianceNum or4 "HolyRadianceNum  4")
AddListItem(HolyRadianceNum or5 "HolyRadianceNum  5" default)
AddListItem(HolyRadianceNum or6 "HolyRadianceNum  6")
AddListItem(HolyRadianceNum or7 "HolyRadianceNum  7")
AddListItem(HolyRadianceNum or8 "HolyRadianceNum  8")
AddListItem(HolyRadianceNum or9 "HolyRadianceNum  9")
AddListItem(HolyRadianceNum or10 "HolyRadianceNum  100")

AddFunction HolyRadianceNumValue asValue=1
{
	if List(HolyRadianceNum or0) 0
	if List(HolyRadianceNum or1) 1
	if List(HolyRadianceNum or2) 2
	if List(HolyRadianceNum or3) 3
	if List(HolyRadianceNum or4) 4
	if List(HolyRadianceNum or5) 5
	if List(HolyRadianceNum or6) 6
	if List(HolyRadianceNum or7) 7    
	if List(HolyRadianceNum or8) 8 
	if List(HolyRadianceNum or9) 9 
	if List(HolyRadianceNum or10) 101 
}



Include(ovale_common)
Include(ovale_trinkets_mop)
Include(ovale_trinkets_wod)
Include(ovale_paladin_spells)

AddCheckBox(opt_auto_beacon auto_beacon default specialization=holy)
AddCheckBox(opt_auto_prism auto_prism default specialization=holy)
AddCheckBox(opt_auto_jud auto_jud default specialization=holy)
AddCheckBox(opt_auto_target auto_target default specialization=holy)
AddCheckBox(opt_distance auto_distance specialization=holy)

AddFunction HolyInterruptActions
{
	if CheckBoxOn(opt_interrupt) and not target.IsFriend() and target.IsInterruptible()
	{
		if target.InRange(rebuke) Spell(rebuke)
		if not target.Classification(worldboss)
		{
			if target.InRange(fist_of_justice) Spell(fist_of_justice)
			if target.InRange(hammer_of_justice) Spell(hammer_of_justice)
			Spell(blinding_light)
			Spell(arcane_torrent_holy)
			if target.InRange(quaking_palm) Spell(quaking_palm)
			Spell(war_stomp)
		}
	}
}

AddFunction ApplyBeacons
{
	if GetTarget_ID()==GetMainTank_ID() or GetTarget_ID()==GetOffTank_ID() or target.HealthPercent() <= FlashOfLightValue()
	{
		if target.IsFriend() and not target.BuffPresent(beacon_of_light_buff mine=1) and not target.BuffPresent(beacon_of_faith_buff mine=1) Spell(beacon_of_light)
	}
}

AddFunction HolyPrism
{
	if not focustarget.IsFriend() and focustarget.InRange(holy_prism) Spell(holy_prism) 
	if not targettarget.IsFriend() and targettarget.InRange(holy_prism) Spell(holy_prism) 
}

AddFunction Judgement
{
	if Talent(selfless_healer_talent)
	{
		if not focustarget.IsFriend() Spell(judgment) 
		if not targettarget.IsFriend() Spell(judgment)
	}
}



AddIcon help=main specialization=holy
{
    UpdateRaidAndParty()
	if target.IsFriend()
	{
		if CheckBoxOn(opt_auto_beacon) ApplyBeacons()
		Spell(holy_shock)
		if target.HealthPercent() <= LayOnHandsValue() Spell(lay_on_hands)
		if GetTarget_ID() > 0 and target.HealthPercent() <= HandOfSacrificeValue() and target.BuffExpires(hand_of_sacrifice_buff) Spell(hand_of_sacrifice)
		if InCombat()
		{
			if CheckBoxOn(opt_auto_prism) HolyPrism()
			if CheckBoxOn(opt_auto_jud) Judgement()
		}
		if Talent(selfless_healer_talent) and BuffStacks(selfless_healer_buff) >= 3 Spell(flash_of_light)
		if Speed() ==0 and target.HealthPercent() <= 20
		{
			Spell(avenging_wrath_heal)
			if BuffPresent(infusion_of_light_buff) Spell(holy_light)
			if HolyPower() >= 3 or BuffPresent(divine_purpose_buff) Spell(word_of_glory)
			Spell(flash_of_light)
		}
		if {HolyPower() >= 3 or BuffPresent(divine_purpose_buff)} 
		{
			if CheckBoxOn(opt_distance) and Speed() ==0 and GetMemberNumBelowHpInRangePlayer(95 30) >= LightOfDawnNumValue() Spell(light_of_dawn)
			if not CheckBoxOn(opt_distance) and Speed() ==0 and GetMembersNumBelow(95) >= LightOfDawnNumValue() Spell(light_of_dawn)
			
		}
		if Speed() ==0 and CheckBoxOn(opt_distance)
		{
			if GetMemberNumBelowHpInRangeTarget(75 10) >= HolyRadianceNumValue() Spell(holy_radiance)
		}
		if not CheckBoxOn(opt_distance) and Speed() ==0
		{
			if GetMembersNumBelow(70) >= HolyRadianceNumValue() Spell(holy_radiance)
		}
		if Speed() ==0 and target.HealthPercent() <= FlashOfLightValue()
		{
			Spell(avenging_wrath_heal)
			if BuffPresent(infusion_of_light_buff) Spell(holy_light)
			if HolyPower() >= 3 or BuffPresent(divine_purpose_buff) Spell(word_of_glory)
			Spell(flash_of_light)
		}
		if Speed() ==0 and BuffPresent(infusion_of_light_buff) and target.HealthPercent() <= HolyLightValue() Spell(holy_light)
		if Speed() ==0 and target.HealthPercent() <= WoGValue() and not target.BuffPresent(eternal_flame_buff) Spell(word_of_glory)
		if not Speed(more 0) and Talent(ethernal_flame_talent) and { {GetMainTank_ID() > 0 and GetTarget_ID()==GetMainTank_ID()} or {GetOffTank_ID() > 0 and GetTarget_ID()==GetOffTank_ID()} }
		{
			if not target.BuffPresent(eternal_flame_buff) Spell(word_of_glory)
		}
		if Speed() ==0 and target.HealthPercent() <= HolyLightValue() Spell(holy_light)	
		if HolyPower() >= 5 Spell(light_of_dawn)
		
	}
	
}



AddIcon help=target specialization=holy
{	
    
	UpdateRaidAndParty()
	if CheckBoxOn(opt_auto_target)
	{
		if HealthPercent() <= 40
		{return 0}
		else
		{
			if GetLowestHP_HP() <= 20
				{return GetLowestHP_ID()}
			else
			{
				if Talent(ethernal_flame_talent) and {MainTankNeedMyBuff() or OffTankNeedMyBuff()} and HolyPower() > 0 and GetLowestHP_HP() > FlashOfLightValue() and GetLowestHP_HP() > LayOnHandsValue() and GetLowestHP_HP() > WoGValue()
				{
						if MainTankNeedMyBuff() 
						{
							if GetTarget_ID() == GetMainTank_ID() and IsPlayer()
							{
								return 100
							}
							else
							{
								return GetMainTank_ID()
							}
						}
						else if OffTankNeedMyBuff()
						{
							if GetTarget_ID() == GetOffTank_ID() and IsPlayer()
							{
								return 100
							}
							else
							{
								return GetOffTank_ID()
							}
						}
				}
				else
				{
					if GetLowestHP_HP() < 99
					{
						if GetTarget_ID() == GetLowestHP_ID() and IsPlayer()
						{
							return 100
						}
						else
						{
							return GetLowestHP_ID()
						}
					}
					else
					{
						if GetTarget_ID() == GetMainTank_ID() and IsPlayer()
						{
							return 100
						}
						else
						{
							return GetMainTank_ID()
						}
					}
					
				}
			}
		}	
	}
}

AddIcon help=distance specialization=holy
{
	#OffTankNeedMyBuff()
	#GetMainTank_ID()
	#GetOffTank_ID()
	AdvancedDistanceFromTarget()
	#Spell(hand_of_sacrifice)
	#MainTankNeedMyBuff()
	#Talent(ethernal_flame_talent)
	#GetLowestHP_HP()
	#MyTargetID()
	
}



### Required symbols
# arcane_torrent_holy
# ardent_defender
# ardent_defender_buff
# avengers_shield
# bastion_of_glory_buff
# bastion_of_power_buff
# berserking
# blessing_of_kings
# blessing_of_might
# blinding_light
# blood_fury_apsp
# consecration
# consecration_debuff
# crusader_strike
# divine_protection
# divine_protection_buff
# divine_purpose_buff
# draenic_armor_potion
# empowered_seals_talent
# eternal_flame
# eternal_flame_buff
# execution_sentence
# fist_of_justice
# flash_of_light
# glyph_of_double_jeopardy
# glyph_of_double_jeopardy_buff
# glyph_of_final_wrath
# glyph_of_focused_shield
# grand_crusader_buff
# guardian_of_ancient_kings
# guardian_of_ancient_kings_buff
# hammer_of_justice
# hammer_of_the_righteous
# hammer_of_wrath
# holy_avenger
# holy_avenger_buff
# holy_avenger_talent
# holy_prism
# holy_wrath
# judgment
# liadrins_righteousness_buff
# lights_hammer
# quaking_palm
# rebuke
# righteous_fury
# righteous_fury_buff
# sacred_shield
# sacred_shield_buff
# sanctified_wrath_talent
# seal_of_insight
# seal_of_righteousness
# selfless_healer_buff
# selfless_healer_talent
# seraphim
# seraphim_buff
# seraphim_talent
# shield_of_the_righteous
# shield_of_the_righteous_buff
# speed_of_light
# uthers_insight_buff
# war_stomp
]]
	OvaleScripts:RegisterScript("PALADIN", "holy", name, desc, code, "script")
end
